/**
 * Copyright (c) 2015-2030 by Beijing Yanlight Co., Ltd.
 * All rights reserved.
 */
package com.yanlight.support.event.handler;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import com.yanlight.support.push.Pusher;
import com.yanlight.type.OrderSceneType;
import com.yanlight.support.event.OrderPayNotifyEvent;

/**
 * 
 * @author haolw
 * @time 2017/09/28
 */
@Component
public class OrderPayNotifyHandler implements ApplicationListener<OrderPayNotifyEvent> {

	@Autowired
	private Pusher pusher;

	@Async
	public void onApplicationEvent(OrderPayNotifyEvent event) {
		pusher.pushCompanyPayNotify(event);
		Integer sceneType = event.getSceneType();

		// 消费者主动扫分店APP上绑定的静态码、动态码
		if (OrderSceneType.USER_SCAN_DYNAMIC.getType().equals(sceneType)) {
			pusher.pushCompanyItemPayNotify(event);
		} else if (OrderSceneType.USER_SCAN_BIND_STATIC.getType().equals(sceneType)) {
			pusher.pushCompanyItemPayNotify(event);
		}
	}

}
